package com.itheima.controller;

import com.itheima.pojo.*;
import com.itheima.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import static com.itheima.pojo.Result.success;

@RestController
@RequestMapping("/emps")
public class EmpController {

    @Autowired
    private EmpService empService;

    @GetMapping
    //page是当前页面，pageSize是每页展示记录数
    public Result page(EmpQueryParam empQueryParam) {
        PageResult<Emp> pageResult = empService.page(empQueryParam);
        return success(pageResult);
    }

    @PostMapping
    public Result save(@RequestBody Emp emp) {
        empService.save(emp);
        return success();


    }
}
